{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<div id="tip_modal">
    <form class="layui-form p-4">
        <h3 class="pb-3">功能菜单/节点</h3>
        <table class="layui-table layui-table-form">
            <tr>
                <td class="layui-td-gray">单据编号</td>
                <td>{$detail.orderNum}</td>
                <td class="layui-td-gray">供应商名称</td>
                <td>{$detail.pName}</td>
                <td>业务类型</td>
                <td>{$detail.reconcile_type==1?'产品对账':'金额对账'}</td>
            </tr>
            <tr>
                <td class="layui-td-gray">产品编码</td>
                <td>{$detail.bar_code}</td>
                <td class="layui-td-gray">产品名称</td>
                <td>   {$detail.mdName}</td>
                <td class="layui-td-gray">规格型号</td>
                <td>   {$detail.specs}</td>
            </tr>
            <tr>
                <td class="layui-td-gray">对账金额 </td>
                <td>
                    {$detail.reconcilePrice}
                </td>
                <td class="layui-td-gray">状态</td>
                <td>

                        {foreach [['id'=>1,'name'=>'草稿'],['id'=>2,'name'=>'已确认']] as $st}
                         {if isset($detail.status)&&$detail.status==$st.id } {$st.name}{/if}
                        {/foreach}


                </td>
                <td class="layui-td-gray">对账日期</td>
                <td>
                    {$detail.reconcileDate|default=''}
                </td>
            </tr>
            <tr>
                <td class="layui-td-gray">未对账数量 </td>
                <td>
                    {$detail.unReconcile}
                </td>
                <td class="layui-td-gray">本次对账数量</td>
                <td>
                    <input id="reconcileNum"{if $detail.reconcile_type ==2} readonly{else}onblur="changePrice()" {/if} name="reconcileNum" type="text" class="layui-input" required placeholder="请输入数量"
                           value="{$detail.reconcileNum}" onkeyup="digitalFiltering(this,0)" >
                </td>
                <td class="layui-td-gray"></td>
                <td>

                </td>
            </tr>
        </table>
        <div class="py-3">
            <input type="hidden" name="id" value="{$id}">
            <input type="hidden" name="unitPirce" id="unitPirce" value="{$detail.unitPirce}">
            <input type="hidden" name="reconcilePrice" id="reconcilePrice" value="{$detail.reconcilePrice}">
            {if !isset($detail.status)||$detail.status==1}
            <button class="layui-btn layui-btn-normal" type="button" id="sub" lay-submit="" lay-filter="webform1">保存 </button>
            {/if}
<!--            {if isset($detail.status)&&$detail.status==1}-->
<!--            <button type="button" class="layui-btn layui-btn-normal" onclick="onSure()">确认</button>-->
<!--            {/if}-->
        </div>
    </form>
</div>

{/block}
<!-- /主体 -->
{block name="script"}
<script>

    const moduleInit = ['tool'];

    let isSub = 2;

    function gouguInit() {
        var form = layui.form, tool = layui.tool;
        //监听提交
        form.on('submit(webform1)', function (data) {
            let callback = function (e) {
                isSub = 2;
                layer.msg(e.msg);
                if (e.code == 0) {
                    setTimeout(function () {
                        parent.parent.location.reload();
                    }, 1000);
                }
            }
            if (isSub == 2) {
                isSub = 1
                tool.post("{:url('add')}", data.field, callback);
            }
            return false;
        });


    }
</script>
<script>
    function changePrice() {
        var num=$("#reconcileNum").val();
        if (num==''){
            layer.msg('请输入数量');
            return;
        }
        var unitPrice=$("#unitPirce").val();
        var reconcilePrice=num*unitPrice;
        console.log('recon',reconcilePrice)
        $('#reconcilePrice').val(reconcilePrice);
    }
</script>
{/block}
<!-- /脚本 -->